package com.only4play.productcenter.infrastructre.converter;

import com.only4play.productcenter.api.constans.InOutStoreType;

import javax.persistence.AttributeConverter;

public class InOutStoreTypeConverter implements AttributeConverter<InOutStoreType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(InOutStoreType inOutStoreType) {
    return inOutStoreType.getCode();
  }

  @Override
  public InOutStoreType convertToEntityAttribute(Integer code) {
    return InOutStoreType.of(code).orElse(null);
  }
}
